package nju.mscs.data.object;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class PromotionList implements Serializable{
	
	protected ArrayList<Promotion> promotionList = new ArrayList<Promotion>();
	
	List<GiftPromotion> getGiftPromotion(double total) {
		ArrayList<GiftPromotion> list = new ArrayList<GiftPromotion>();
		for(Promotion p:promotionList)
			if(p.getType() == Promotion.TotalGiftPromotion)
				if(((TotalGiftPromotion)p).check(total))
					list.add((GiftPromotion) p);
		return list;
	}
	List<GiftPromotion> getGiftPromotion(Goods goods) {
		ArrayList<GiftPromotion> list = new ArrayList<GiftPromotion>();
		for(Promotion p:promotionList)
			if(p.getType() == Promotion.GoodsGiftPromotion)
				if(((GoodsGiftPromotion)p).check(goods))
					list.add((GiftPromotion) p);
		return list;
	}
	
	List<DiscountPromotion> getDiscountPromotion(double total){
		List<DiscountPromotion> list = new ArrayList<DiscountPromotion>();
		for(Promotion p:promotionList)
			if(p.getType() == Promotion.TotalDiscountPromotion)
				if(((TotalDiscountPromotion)p).check(total))
					list.add((DiscountPromotion) p);
		return list;
	}
	List<DiscountPromotion> getDiscountPromotion(Goods goods){
		List<DiscountPromotion> list = new ArrayList<DiscountPromotion>();
		for(Promotion p:promotionList)
			if(p.getType() == Promotion.GoodsDiscountPromotion)
				if(((GoodsDiscountPromotion)p).check(goods))
					list.add((DiscountPromotion) p);
		return list;
	}
}